# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_gemname=titlecase
pkgname=ruby-titlecase
_gitcommit=1d6b4f760ae753440db4e7ccf0e0ddba621bf25f
pkgver=0.1.1+13+1d6b4f7
pkgrel=5
pkgdesc="Ruby version of John Gruber's TitleCase.pl"
url='https://github.com/samsouder/titlecase'
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('git' 'ruby-rdoc')
options=('!emptydirs')
source=(${pkgname}::"git+https://github.com/samsouder/titlecase#commit=${_gitcommit}")
sha512sums=('SKIP')

pkgver() {
  cd ${pkgname}
  printf "%s+%s+%s" \
    "$(grep version ${_gemname}.gemspec|sed -r 's/.+s.version = "(.+)"/\1/')" \
    "$(git rev-list --count HEAD)" \
    "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${pkgname}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec # don't give a fuck about rubys bla bla
  sed 's|git ls-files|find|' -i ${_gemname}.gemspec
}

build() {
  cd ${pkgname}
  gem build ${_gemname}.gemspec
}

package() {
  cd ${pkgname}
  local _gemdir="$(gem env gemdir)"
  local _gemver="$(grep version ${_gemname}.gemspec|sed -r 's/.+s.version = "(.+)"/\1/')"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${_gemver}.gem
  install -Dm 644 README -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 README -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${_gemver}.gem"
}

# vim: ts=2 sw=2 et:
